package com.example.exam.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.exam.mapper.AchievementMapper;
import com.example.exam.pojo.Achievement;
import com.example.exam.service.AchievementService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhozixiong
 * @date 2023/03/10
 */
@Service
public class AchievementServiceImpl extends ServiceImpl<AchievementMapper, Achievement> implements AchievementService {

    @Override
    public void insert(Achievement achievement) {
        baseMapper.insert(achievement);
    }

    @Override
    public Achievement searchAllBySidAndTid(Achievement achievement) {
        QueryWrapper<Achievement> wrapper = new QueryWrapper<>();
        wrapper.eq("sid", achievement.getSid());
        wrapper.eq("tid", achievement.getTid());
        return baseMapper.selectOne(wrapper);
    }

    @Override
    public List<Achievement> searchAllBySid(String sid) {
        QueryWrapper<Achievement> wrapper = new QueryWrapper<>();
        wrapper.eq("sid", sid);
        return baseMapper.selectList(wrapper);
    }

    @Override
    public void updateAchievementBySidAndTid(Achievement achievement) {
        baseMapper.updateAchievementBySidAndTid(achievement);
    }

    @Override
    public int searchAchievementBySid(String sid) {
        return baseMapper.searchAchievementBySid(sid);
    }
}
